<%--
  Created by IntelliJ IDEA.
  User: CY
  Date: 2018/1/4
  Time: 10:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
<head>
    <title>企业巡检</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8 ? MYOA_CHARSET : htmlspecialchars($HTML_PAGE_CHARSET))?>" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/css/street/street.css"/>
    <link rel="stylesheet" href="/css/officialDocument/officialDocument.css">
    <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <%--<link rel="stylesheet" type="text/css" href="/css/patrol/patrol.css"/>--%>
    <link rel="stylesheet" href="/css/base.css">
    <script src="../js/jquery/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layer/layer.js?20201106" type="text/javascript" charset="utf-8"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/base/tablePage.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <style>
        body{
            margin:0px;
        }
        .info{
            width:180px;
            height:28px;
            border-radius: 3px;
            margin-left:34px;
            vertical-align: middle;
        }
        button{
            background: #2f8ae3;
            margin-left: 10px;
            padding: 5px 10px;
            border-radius: 4px;
            color: #fff;
            cursor: pointer;
            font-size:14px;
        }
        #add{
            float:right;
            margin:0px 20px 0px 0px;
        }
        .table{
            width:96%;
            margin:20px auto 0px;
        }
        .tableFoot{
            margin-top:20px;
        }
        .childCheck{
            width:16px;
            vertical-align: middle;
        }
        #checkAll{
            margin-left:10px;
        }
        /*#outport{*/
            /*background: #009900;*/
        /*}*/
        #inportEdit{
            background: #009900;
        }
        .M-box3 .active{
            margin: 0px 3px;
            width: 29px;
            height: 29px;
            line-height: 29px;
            background: #2b7fe0;
            font-size: 12px;
            border: 1px solid #2b7fe0;
            color:#fff;
            text-align:center;
            display: inline-block;
        }
        .M-box3 a{
            margin: 0 3px;
            width: 29px;
            height: 29px;
            line-height: 29px;
            font-size: 12px;
            display: inline-block;
            text-align:center;
            background: #fff;
            border: 1px solid #ebebeb;
            color: #bdbdbd;
            text-decoration: none;
        }
        .mainBg .mainTitle{
            min-width: 750px;
        }
        .mainTitleUl .bordercolor span{
            font-size:14px;
        }
        .mainTitleUl .bordercolor label input[type=text]{
            font-size:14px;
        }
        .mainBg{
            padding-top:0px;
        }
        ul .pic{
            padding-left:5px!important;
        }
        .lue{
            width:200px;
            overflow: hidden;
            margin:0 auto;
            text-overflow:ellipsis;
            white-space:nowrap;
        }
    </style>
    <link rel="stylesheet" href="/css/biaodan.css">
</head>
<body>
<div class="content" style="padding-top:55px;">
    <div class="tableList" >
        <div class="headNav">
            <input type="text" class="info" placeholder="处理结果">
            <%--<select class="info" name="xiala" id="">
                <option value="">所有处理结果</option>
                <option value="完成">完成</option>
                <option value="未完成">未完成</option>
            </select>--%>
            <button id="query">查询</button>
            <%--<button id="inport">导入</button>--%>
            <%--<button id="inportEdit">导入修改</button>--%>
            <%--<button class="choose" id="add" data-type="0">新建</button>--%>
        </div>
        <div class="table">
            <table>
                <thead>
                <tr>
                    <th style="width:1%"></th>
                    <th>序号</th>
                    <th>污染源名称</th>
                    <th>污染源位置</th>
                    <th>巡查人员</th>
                    <th>上报时间</th>
                    <th>问题类型</th>
                    <th>处理结果</th>
                    <%--<th>卫生许可证</th>--%>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody class="list">

                </tbody>
            </table>
            <div class="tableFoot">
                <input type="checkbox" id="checkAll"  style="width:16px;vertical-align: middle">
                <label for="checkAll" style="font-size:14px;">全选</label>
                <button id="outport">导出</button>
            </div>
            <div style="margin: -40px auto 0px;height:50px;width: 97%;" class="clearfix">
                <div id="dbgz_page" class="M-box3" style="display: none">

                </div>
            </div>
        </div>

    </div>
    <div class="mainBg" style="background: #fff;display: none">
        <form action="" id="datasave">
            <input type="file"  onchange="filesTwo(this)" multiple="multiple" name="file"
                   style="display: none"/>
            <input type="hidden" name="problemType">
            <%--<input type="hidden" name="reportTime">--%>
            <div class="mainTitle">
                <ul class="mainTitleUl">
                    <li style="    padding-top: 18px;text-align: center;height: 61px;border-bottom: 1px solid #ddd"><span class="spanSize">企业巡检单</span> </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff">问题类别</span>
                        <label>
                            <input type="text" name="prolemType" placeholder="请填写问题类别" style="background: #fcfcfc;    width: 92%;
    float: none;
    margin-top: 0px; margin-top: 8px;">
                        </label>
                        <label style="width: 50%;"></label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff">所属区县
                            <%--<b style="color: red;vertical-align: middle; margin-top: 8px;">*</b>--%>
                        </span>
                        <label>
                            <input type="text" name="subCounty" placeholder="请填写所属区县" style="background: #fcfcfc;    width: 92%;
    float: none;
    margin-top: 8px;">
                        </label>
                        <label style="width: 50%;"></label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff">所属乡镇</span>
                        <label>
                            <input type="text" name="subVillage" placeholder="请填写所属乡镇" style="background: #fcfcfc;    width: 92%;float: none;margin-top: 0px; margin-top: 8px;">
                        </label>
                        <label style="width: 50%;"></label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff">上报时间</span>
                        <label>
                            <input type="text" id="time" name="reportTime" placeholder="请填写上报时间" style="background: #fcfcfc;    width: 92%;float: none;margin-top: 0px; margin-top: 8px;">
                        </label>
                        <label style="width: 50%;"></label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff">巡查人员</span>
                        <label>
                            <input type="text" name="patrolUser" placeholder="请填写巡查人员" style="background: #fcfcfc;    width: 92%;float: none;margin-top: 0px; margin-top: 8px;">
                        </label>
                        <span style="border-bottom: 1px solid #fff">联系方式</span>
                        <label>
                            <input type="text" name="contact" placeholder="请填写巡查联系方式" style="background: #fcfcfc;    width: 92%;float: none;margin-top: 0px; margin-top: 8px;">
                        </label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff">存在问题</span>
                        <label>
                            <input type="text" name="existingProblem" placeholder="请填写存在问题" style="background: #fcfcfc; margin-left: 4%;   width: 261%;float: none;margin-top: 0px; margin-top: 8px;">
                        </label>
                        <label style="width: 50%;"></label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff">污染源名称 <b style="color: red;">*</b></span>
                        <label>
                            <input type="text" name="pollutionName" placeholder="请填写污染源名称" style="background: #fcfcfc; margin-left: 4%;   width: 261%;float: none;margin-top: 0px; margin-top: 8px;">
                        </label>
                        <label style="width: 50%;"></label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff">污染源位置</span>
                        <label>
                            <input type="text" name="pollutionLocation" placeholder="请填写污染源位置" style="background: #fcfcfc; margin-left: 4%;   width: 261%;float: none;margin-top: 0px; margin-top: 8px;">
                        </label>
                        <label style="width: 50%;"></label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #f1f5f8;height: 62px;line-height: 99px">问题类型</span>
                        <label style="width: 15%;height: 62px;text-align: left;font-size: 16px;   border-bottom: none;">
                            <input style="width: 15px;height: 59px;" type="checkbox" class="ipt" name="居民散煤">居民散煤
                        </label>
                        <label style="width: 15%;height: 62px;text-align: left;font-size: 16px;    border-bottom: none;">
                            <input style="width: 15px;height: 59px;" type="checkbox" class="ipt" name="道路扬尘">道路扬尘
                        </label>
                        <label style="width: 15%;height: 62px;text-align: left;font-size: 16px;    border-bottom: none;">
                            <input style="width: 15px;height: 59px;" type="checkbox" class="ipt" name="工地扬尘">工地扬尘
                        </label>
                        <label style="width: 15%;height: 62px;text-align: left;font-size: 16px;    border-bottom: none;">
                            <input style="width: 15px;height: 59px;" type="checkbox" class="ipt" name="工业废气">工业废气
                        </label>
                        <label style="width: 15%;height: 62px;text-align: left;font-size: 16px;    border-bottom: none;">
                            <input style="width: 15px;height: 59px;" type="checkbox" class="ipt" name="餐饮油烟">餐饮油烟
                        </label>

                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff"></span>
                        <label style="width: 18%;text-align: left;font-size: 16px;">
                            <input style="width: 15px;height: 59px;" type="checkbox" class="ipt" name="散乱污">散乱污
                        </label>
                        <label style="width: 18%;text-align: left;font-size: 16px;">
                            <input style="width: 15px;height: 59px;" type="checkbox" class="ipt" name="着火点">着火点
                        </label>
                        <label style="width: 25%;text-align: left;font-size: 16px;">
                            <input style="width: 15px;height: 59px;" type="checkbox" class="ipt" name="燃煤锅炉(小茶炉)">燃煤锅炉(小茶炉)
                        </label>
                        <label style="width: 19%;text-align: left;font-size: 16px;">
                            <input style="width: 15px;height: 59px;" type="checkbox" class="ipt" name="其他">其他
                        </label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff">情况说明</span>
                        <label>
                            <input type="text" name="situationDes" placeholder="请填写情况说明" style="background: #fcfcfc;    width: 92%;
    float: none;
    margin-top: 8px;">
                        </label>
                        <label style="width: 50%;"></label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff">处理结果</span>
                        <label>
                            <input type="text" name="processResult" placeholder="请填写处理结果" style="background: #fcfcfc;  margin-left: 4%;  width: 261%;
    float: none;
    margin-top: 8px;">
                        </label>
                        <label style="width: 50%;"></label>
                    </li>
                    <form id="dass" action="">
                        <li class="bordercolor clearfix">
                            <span style="border-bottom: 1px solid #fff;height: 100px;line-height: 100px">照片</span>
                            <label style="width: 80%;height: 100px;">
                                <div class="picture prevTwo" style="position: relative">
                                    <input type="hidden" name="attachmentId">

                                    <img class="fl addPhotos" style="    width: 60px;cursor: pointer;
    height: 60px;
    margin-top: 4px;
    margin-right: 7px;" src="/img/grid/addtupin.png" alt="添加照片">
                                    <input type="hidden" name="attachmentName">

                                    <ul class="fl">

                                    </ul>

                                    <%--style="display:none;position: absolute;width: 68px;height: 30px;top: 27px;right: 5px;"--%>

                                </div>
                            </label>
                        </li>
                    </form>


                </ul>
                <div style="height: 88px;line-height: 88px;text-align: center">
                    <a href="javascript:void (0)" class="preservation" style="
                margin-top: 25px;display: inline-block;margin-right: 10px;
                line-height: 1;font-size:18px;padding: 8px 20px;
                background: #2F8AE3;color: #fff;border-radius: 6px">保存</a>
                    <a href="javascript:void (0)" class="getBack"  style="
                margin-top: 25px;display: inline-block;
                line-height: 1;font-size:18px;padding: 8px 20px;background: #2F8AE3;color: #fff;border-radius: 6px">返回</a>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    $(document).on('click','.choose',function(){
        var type=$(this).attr('data-type');
        $('.tableList').hide();
        $('.mainBg').show();
        if(type==0){//新建
            $('.preservation').attr('data-type','0');
            $('#datasave').attr('action','/enCaterParameter/insertSelective')
        }else if(type==1){//查看
            var id=$(this).parents('tr').attr('id')
            $('.preservation').hide();
            $('.addPhotos').hide();
            noUser();
            detail(id,type)
        }else{//修改
            var id=$(this).parents('tr').attr('id')
            $('.preservation').attr('data-type','2')
            $('.preservation').show();
            $('.addPhotos').show();
            $('.preservation').attr('data-id',id);
            $('#datasave').attr('action','/communitypatrol/updatePatrol?patrolId='+id)
            use();
            detail(id,type)
        }
    })
    //    点击返回
    $('.getBack').click(function(){
        $('.tableList').show();
        $('.mainBg').hide();
    })
    //    禁用
    function noUser(){
        $('.mainBg input[type="text"]').attr('disabled','disabled');
        $('.mainBg input[type="radio"]').attr('disabled','disabled');
        $('.mainBg input[type="checkbox"]').attr('disabled','disabled');
        $('textarea').attr('disabled','disabled');
    }
    //    可以使用
    function use(){
        $('input[type="text"]').removeAttr('disabled');
        $('input[type="radio"]').removeAttr('disabled');
        $('input[type="checkbox"]').removeAttr('disabled','disabled');
        $('textarea').removeAttr('disabled');
    }

    function check(name){
        if(name == undefined){
            return ''
        }else{
            return name;
        }
    }

    //    分页列表
    var ajaxPageLe={
        data:{
            page:1,//当前处于第几页
            pageSize:10,//一页显示几条
            useFlag:true
            // computationNumber:null
        },
        page:function () {
            var me=this;
            $.ajax({
                url:'/communitypatrol/getPatrolInfo',
                type:'get',
                data:me.data,
                dataType:'json',
                success:function(reg){
                    var datas=reg.data;
                    var str="";
                    var sts="";
                    var s='';
                    for(var i=0;i<datas.length;i++){
                        if(datas[i].problemType==undefined){
                            datas[i].problemType=''
                        }
                        sts =datas[i].problemType;
                        var sj =getNowFormatDate(datas[i].reportTime);
                        sts=String(sts)
                        s=sts.substring(0,sts.length-1);
                        str+=' <tr id="'+datas[i].patrolId+'">' +
                            '                    <td>' +
                            '                        <input type="checkbox" class="childCheck">' +
                            '                    </td>' +
                            '                    <td>'+(i+1)+'</td>' +
                            '                    <td><div class="lue" title="'+datas[i].pollutionName+'"><a href="javascript:;" class="choose" data-type="1">'+function(){
                            if(datas[i].pollutionName==undefined){
                                return ''
                            }else{
                                return datas[i].pollutionName
                            }
                            }()+'</a></div></td>'+
                            '                    <td>'+function(){
                                                if(datas[i].pollutionLocation!=undefined){
                                                    return datas[i].pollutionLocation;
                                                }else{
                                                    return '';
                                                }
                            }()+'</td>' +
                            '                    <td>'+function(){
                                                    if(datas[i].patrolUser == undefined){
                                                        return ''
                                                    }else{
                                                        return datas[i].patrolUser
                                                    }
                            }()+'</td>' +
                            '                    <td>'+sj+'</td>' +
                            '                    <td style="width: 146px;">'+s+'</td>' +
                            '                    <td>'+function(){
                                                    if(datas[i].processResult!=undefined){
                                                        return datas[i].processResult;
                                                    }else{
                                                        return '';
                                                    }
                            }()+'</td>' +
                            '                    <td>' +
                            /*'                        <a href="javascript:;" class="choose" data-type="1">查看</a>' +*/
                            '                        <a href="javascript:;" class="choose" data-type="2">修改</a>' +
                            '                        <a href="javascript:;" class="del">删除</a>' +
                            '                    </td>' +
                            '                </tr>'
                    }
                    $('.list').html(str);
                    console.log(reg.total)
                    if(reg.total>10){
                        $('#dbgz_page').show();
                        me.pageTwo(reg.total,me.data.pageSize,me.data.page)
                    } else {
                        $('#dbgz_page').hide();
                    }

                }
            })

        },
        pageTwo:function (totalData, pageSize,indexs) {
            var mes=this;
            $('#dbgz_page').pagination({
                totalData: totalData,
                showData: pageSize,
                jump: true,
                coping: true,
                homePage:'',
                endPage: '',
                current:indexs||1,
                callback: function (index) {
                    mes.data.page=index.getCurrent();
                    mes.page();
                }
            });
        }
    }
    ajaxPageLe.page();
    //    点击全选
    $('#checkAll').click(function(){
        var state=$(this).prop('checked');
        if(state == true){
            $(this).prop('checked',true);
            $('.childCheck').prop('checked',true);
        }else{
            $(this).prop('checked',false);
            $('.childCheck').prop('checked',false);
        }
    })
    //    点击删除
    $('.list').on('click','.del',function(){
        var id=$(this).parents('tr').attr('id')
        layer.confirm(' 确定要删除吗', {
            btn: ['确定', '取消'], //按钮
            title: " 删除"
        },function(){
            $.ajax({
                url:'/communitypatrol/deletePatrol',
                type:'post',
                dataType:'json',
                data:{id:id},
                success:function(){
                    layer.msg(' 删除成功', {icon: 6});
                    ajaxPageLe.page();
                }
            })
        }, function () {
            layer.closeAll();
        })
    })

    //    获取所属社区下拉框内容
    $.get('/code/getCode?parentNo=TYPE_OF_ACCOUNT',function (json) {
        if(json.flag){
            var str='<option value="">请选择</option>';
            for(var i=0;i<json.obj.length;i++){
                str+='<option value="'+json.obj[i].codeNo+'">'+json.obj[i].codeName+'</option>'
            }
            $('#grid').html(str)
        }
    })

    //上传图片
    function filesTwo(mes) {
        var arr=mes.files;
        var bool=true;
        for(var i=0;i<arr.length;i++){
            if(arr[i].name.indexOf('.png')==-1&&arr[i].name.indexOf('.jpg')==-1&&arr[i].name.indexOf('.PNG')==-1&&arr[i].name.indexOf('.JPG')==-1){
                bool=false;
                break;
            }
        }
        if(!bool){
            $.layerMsg({content:'只能上传.png或.jpg格式！',icon:2});
            return
        }
        $('#datasave').prop('action','/flow/fileUpload?module=parameter')

        $('#datasave').ajaxSubmit({
            type:'post',
            dataType:'json',
            success:function (json) {
                if(json.flag) {
                    console.log(json)
                    var str='';
                    var arr=json.datas;
                    var attStrId='';
                    var attStrName='';
                    for(var i=0;i<arr.length;i++){

                        attStrId+=arr[i].attStrId+',';
                        attStrName+=arr[i].attStrName+'*';
                        str+='<li class="pic" style="width: 60px;height: 60px;float:left">' +
                            '<b class="deleClear" style="position: absolute">x</b>' +
                            '<img src="/xs?'+arr[i].attUrl+'" alt="">' +
                            '<input type="hidden" class="hiddenId" value="'+arr[i].attStrId+'">' +//id
                            '<input type="hidden" class="hiddenName" value="'+arr[i].attStrName+'">' +//名字
                            '</li>'
                    }
                    $(me).siblings('ul').html(str)
                    $(me).prev().val(attStrId)
                    $(me).next().val(attStrName)
                }else {
                    alert('异常')
                }

            }
        })

    }

    $(document).delegate('.deleClear','click',function () {
        $(this).parent().remove()
    })

    $('.addPhotos').click(function () {
        me=this;
        $('[name="file"]').click()
    })

    //    点击保存
    $('.preservation').click(function(){
        if($('input[name="pollutionName"]').val()==''){
            $.layerMsg({content:'请输入污染源名称',icon:6});
            return;
        }
        var str1 = '';
        $('.ipt:checked').each(function () {
            var id=$(this).attr('name');
            str1 += id+','
        })
        $("input[name='problemType']").val(str1)

        var attIdLen=$('.hiddenId').length;
        var attNameLen=$('.hiddenName').length;
        var attId="";
        var attName="";
        for(var i=0;i<attIdLen;i++){
            attId += $('.hiddenId').eq(i).attr('value')+','
        }
        for(var i=0;i<attNameLen;i++){
            attName += $('.hiddenName').eq(i).attr('value')+'*'
        }
        $('input[name="attachmentId"]').val(attId)//图片id
        $('input[name="attachmentName"]').val(attName)//图片名称
        var type=$(this).attr('data-type');
        if(type==0){//新建

            $('#datasave').ajaxSubmit({
                type:'post',
                dataType:'json',
                success:function(res){
                    if(res.flag){
                        $.layerMsg({content:'新建成功',icon:1})
                        $('.tableList').show();
                        $('.mainBg').hide();
                        ajaxPageLe.data.page=1;
                        ajaxPageLe.page();
                    }else{
                        $.layerMsg({content:'新建失败',icon:1})
                    }
                }
            })
        }else if(type==2){
            var id=$(this).attr('data-id')
            $('#datasave').attr('action','/communitypatrol/updatePatrol?patrolId='+id)
            var strx=""
            $('.childCheck:checked').each(function(){
                var id=$(this).parents('tr').attr('id');
                strx += id+','
                console.log(str);
            })
            var remindTimes = $("#time").val();
            var strs = remindTimes.toString();
            strs = strs.replace("/-/g", "/");
            var oDate1 = new Date(strs);

            $('#datasave').ajaxSubmit({
                type:'post',
                dataType:'json',
                success:function(res){
                    if(res.flag){
                        $.layerMsg({content:'修改成功',icon:1})
                        $('.tableList').show();
                        $('.mainBg').hide();
                        ajaxPageLe.data.page=1;
                        ajaxPageLe.page();
                    }else{
                        $.layerMsg({content:'修改失败',icon:1})
                    }
                }
            })
        }
    })

    //    查看详情
    function  detail(id,type) {

        var ck;
        $.ajax({
            url:'/communitypatrol/getdetails',
            data:{id:id},
            dataType:'json',
            type:'get',
            success:function(res){
                $('input[type="checkbox"]').prop('checked',false);
                var data=res.data;
                ck = data.problemType
                console.log(ck)
                if(ck.indexOf(",") > 0){
                    cks=ck.split(",")
                    for (var i=0;i<cks.length;i++){
                        cbox(cks[i])
                    }
                }else {
                    cbox(ck)
                }

                var ssj =getNowFormatDate(data.reportTime)
                $('input[name="prolemType"]').val(data.prolemType);
                $('input[name="subCounty"]').val(data.subCounty);
                $("input[name='subVillage']").val(data.subVillage)//所属社区
                $('input[name="contact"]').val(data.contact);//联系人
                $("input[name='reportTime']").val(ssj)
                $("input[name='patrolUser']").val(data.patrolUser)
                $("input[name='existingProblem']").val(data.existingProblem)
                $("input[name='pollutionName']").val(data.pollutionName)
                $("input[name='pollutionLocation']").val(data.pollutionLocation)
                $("input[name='situationDes']").val(data.situationDes)
                $("input[name='processResult']").val(data.processResult)
                check('diningType',data.diningType)//餐饮类型
                check('businessLicense',data.businessLicense)//营业执照
                check('sanitaryPermit',data.sanitaryPermit)//卫生许可证
                $('#note').html(data.note);//备注


                //                    图片显示
                var obj=data.attachmentList;
                var str1=""
                for(var i=0;i<obj.length;i++){
                    str1+='<li class="pic"  class="padding-left:10px;">' +
                        '<img src="/xs?'+obj[i].attUrl+'" alt=""  style="cursor:pointer">' +function(){
                            if(type==1){
                                return ''
                            }else{
                                return '<b class="deleClear">x</b>';
                            }
                        }()+
                        '<input type="hidden" class="hiddenId"  value="'+obj[i].aid+'@'+obj[i].ym+'_'+obj[i].attachId+'">' +//id
                        '<input type="hidden"  class="hiddenName" value="'+obj[i].attachName+'">' +//名字
                        '</li>'
                }
                $('.prevTwo>ul').html(str1);
                $('input[name="imageId"]').val(data.imageId)
                $('input[name="imageName"]').val(data.imageName)
            }
        })
    }

    //    ridio check
    function check(name,data){
        $(':radio[name="'+name+'"][value="'+data+'"]').prop('checked','check')

    }
    //    点击查询
    $('#query').click(function(){
        ajaxPageLe.data.processResult=$('.info').val();
        ajaxPageLe.page();
    })

    //回显checkbox
    function cbox(name) {
        $(':checkbox[name="'+name+'"]').prop('checked','check')
    }

    //    点击导入
    $('#inport').click(function(){
        layer.open({
            type:1,
            title: ['动态监控台账信息导入', 'background-color:#2b7fe0;color:#fff;'],
            area: ['600px', '420px'],
            btn: ['导入', '取消'],
            content:'<div>' +
            '<form class="form1" name="form1" id="uploadForm" method="post" action="/enCaterParameter/importEnCaterParameter\n" enctype="multipart/form-data">' +
            '<table class="importTable"> ' +
            '<tr><td style="width: 100px;">下载导入模板：</td><td style="text-align: left;"><a id="model" style="cursor:pointer">动态监控台账信息模板下载</a></td></tr>' +
            '<tr> <td>选择导入文件：</td> <td><input style="width: auto" type="file" name="file"/></td> </tr>' +
            '<tr>' +
            '<td>说明：</td>'+
            '<td style="text-align: left;"><p>1、请导入.xls文件或者.xlsx。</p>'+
//            '<p>2、请填写网格信息中已有网格。</p>'+
            ' </td> ' +
            '</tr>' +
            '</table>' +
            '</form>' +
            '</div>',
            success:function(){
                $('#model').click(function () {
                    window.location.href = encodeURI("/file/grid/business_account.xls");
                });
            },
            yes:function(obj){
                var flag = CheckForm();
                if (flag) {
                    layer.msg("正在导入中，请耐心等候", {icon: 1});
                    $.upload($('#uploadForm'), function (res) {
                        if(res.flag) {
                            layer.msg("导入成功", {icon: 1});
                        }else{
                            layer.msg("导入失败", {icon: 2});
                        }
                    });

                    layer.closeAll();
                }
            }
        })
    })

    //    点击导出
    $('#outport').click(function(){
        var str=""
        $('.childCheck:checked').each(function(){
            var id=$(this).parents('tr').attr('id');
            str += id+','
            console.log(str);
        })
        if(str==""){
            $.layerMsg({content:'至少选择一个',icon:6})
        }else{
            window.location.href= '<%=basePath%>communitypatrol/fileOut?ids='+str;
        }


    })
    var time = {
        elem:'#time',
        format:'YYYY-MM-DD hh:mm:ss',
        min:laydate.now(),
        max:'2999-12-31 23:59:59',
        istime:true,//是否显示时分秒
        istoday:true,//是否显示【今天】的按钮
        isclear:true,//是否显示【清空】的按钮
        festival: true,//是否显示节日
        start: laydate.now(0,"YYYY-MM-DD hh:mm:ss"),  // 开始日期
        fixed: false,   // 是否固定在可视区域
        zIndex: 10000,  // css控制图层的遮罩效果（效果不明显）
        ready: function(dates){  // 选择好日期的回调
            console.log(dates)
        }
    }
    laydate(time);
    $('#time').val(laydate.now(0, 'YYYY-MM-DD hh:mm:ss'));
    function getNowFormatDate(tm) {
        if(tm == undefined){
            return ''
        }else{
            var date = new Date(tm);
            var seperator1 = "-";
            var seperator2 = ":";
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            var Hours = date.getHours();
            var Minutes = date.getMinutes();
            var Seconds = date.getSeconds();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            if (Hours >= 0 && Hours <= 9) {
                Hours = "0" + Hours;
            }
            if (Minutes >= 0 && Minutes <= 9) {
                Minutes = "0" + Minutes;
            }
            if (Seconds >= 0 && Seconds <= 9) {
                Seconds = "0" + Seconds;
            }
            var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
                ' ' + Hours + seperator2 + Minutes +
                seperator2 + Seconds;
            return currentdate;
        }

    }

    $(document).on('click','.pic img',function () {
        var imgs=$(this).attr('src');
        var wt=(document.documentElement.clientWidth || document.body.clientWidth)*0.8;
        var ht=(document.documentElement.clientHeight || document.body.clientHeight)*0.8;
        layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            area:[wt+'px',ht+'px'],
//                offset:'100px',
            skin: 'layui-layer-nobg', //没有背景色
            shadeClose: true,
            content:
//                '<img src="'+imgs+'" width="'+wt+'" height="'+ht+'">'
            '<div style="width: '+wt+'px;height:'+ht+'px;text-align: center">' +
            '<img src="'+imgs+'" style="max-width:'+wt+'px;max-height: '+ht+'px;">' +
            '</div>'
        });

    })

    $(document).on('click','.layui-layer-nobg',function () {
        layer.closeAll()
    })
</script>
</body>
</html>
